#!/usr/bin/env python3
# -*- coding：utf-8 -*-
# module of merge two dict

d1 = {'a': 1, 'b': 2}
d2 = {'c': 3, 4: 'ss'}


# Method 1, python3.5+ needed
d3 = {**d1, **d2}
print('d3=', d3)


# Method 2,merge 2 dict
def merge_dict(x, y):
    z = x.copy()
    z.update(y)
    return z


# Method 3, merge several dict
def merge_several_dict(*d):
    new_d = dict()
    for i in d:
        new_d.update(i)
    return new_d


# Method 4, 序列自增方法
d4 = {k: v for d in (d1, d2) for k, v in d.items()}
print(d4)


if __name__ == '__main__':

    print(merge_several_dict(d1, d2, {'ss': 22}))
    print(merge_dict(d1, d2))
